package com.baishui.gateway.classloader;


import java.util.concurrent.ConcurrentHashMap;

public class ClassLoaderFactory {

    private static ConcurrentHashMap<String, ClassLoader> classLoaders =
            new ConcurrentHashMap<>();

    private static ClassLoaderFactory classLoaderFactory = new ClassLoaderFactory();

    private ClassLoaderFactory() {
    }

    private ClassLoaderFactory getInstant() {
        return classLoaderFactory;
    }

    public void init(String name, ClassLoader classLoader) {
        synchronized (this) {
            classLoaders.put(name, classLoader);
        }
    }

    public ClassLoader getClassLoader(String systemName) {
        return classLoaders.get(systemName);
    }
}
